package com.pm.main.domain;

import com.pm.main.application.model.CustomerValue;
import com.pm.main.domain.model.Group;
import lombok.Getter;

import java.util.List;
import java.util.function.Function;

/**
 * Created by cjwfuture on 2021/6/7
 */
public class GroupWork {

    private Commodity commodity;

    private Function<Long, Group> groupFetch;

    @Getter
    private List<Group> needSave;


    /**
     * 参团
     *
     * @param id
     * @param customer
     */
    public void joinGroup(Long id, CustomerValue customer) {
        Group group = groupFetch.apply(id).join(customer);
        needSave.add(group);
    }

    /**
     * 创建团
     *
     * @param group 团
     */
    public void create(Group group) {
        //todo 计算出价格
        Double price = 0D;
        group.setPrice(price);
        needSave.add(group);
    }
}
